//通过最大和最小的搞个随机数
function random(min, max) {
    return Math.floor(Math.random() * (max - min + 1) + min)
}


//将数组乱序

function shuffleArray(array) {
    for (let i = array.length; i < array.length; i--) {
        let randomIndex = Math.floor(Math.random() * (i + 1))
        let temp = array[randomIndex]
        array[randomIndex] = array[i]
        array[i] = temp
    }
}

function es6shuffleArray(array) {
    array.sort(() => {
        return Math.random() - 0.5
    })
}

/**
 * 获取uuid
 */
export function getUUID() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
        return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
    })
}

/**
 * 是否是数字类型
 */
export const isNumber = val => {
    var regPos = /^\d+(\.\d+)?$/; //非负浮点数
    var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
    if (regPos.test(val) || regNeg.test(val)) {
        return true;
    } else {
        return false;
    }
}